import {http} from "@/axios/axios";
import {http2} from "@/axios/axios2";
import {http3} from "@/axios/axios3";
import axios from "axios";
import {http4} from "@/axios/axios4";
import {http5} from "@/axios/axios5";
import {http6} from "@/axios/axios6";

export const j3api = {
    getServerState() {
        return http.get("/api/spider/server/server_state", {})
    },
    getRoutine() {
        return http2.get("/data/active/current", {})
    },
    getGold() {
        return http2.get("/data/trade/demon", {})
    },
    getNotice() {
        return http2.get('/data/web/announce', {limit: 10})
    },
    getTopic(str: string) {
        return http2.get('/data/exam/answer', {limit: 10, match: str})
    },
    getMeetF(type: number) {
        switch (type) {
            case 1:
                return http3.get('/serendipities', {type: 'perfect', pageIndex: 1, per: 50})
            case 2:
                return http3.get('/serendipities', {type: 'normal', pageIndex: 1, per: 50})
            case 3:
                return http3.get('/serendipities', {type: 'pet', pageIndex: 1, per: 100})
        }
    },
    search(str: string) {
        return axios.request({
            url: 'https://helper.jx3box.com/api/achievement/search',
            params: {
                keyword: str,
                page: 1,
                limit: 15,
                client: 'std'
            }
        })
    },
    getWiki(id: number) {
        return axios.request({
            url: 'https://helper.jx3box.com/api/wiki/post',
            params: {
                client: 'std',
                supply: 1,
                type: 'achievement',
                source_id: id
            }
        })
    },
    searchFlower(data: any) {
        return http2.get("/data/home/flower", data)
    },
    searchImplements(name: string) {
        return http2.get('/data/home/travel', {name: name})
    },
    //获取成就菜单列表
    getAchievementMenu() {
        return http4.get('/api/achievement/menus', {general: 1, client: 'std'})
    },
    getAchievement(id: string) {
        id = id + ''
        if (id.match(RegExp(/-/))) {
            id = id.replace('-', '/')
        }
        console.log(id);
        return http4.get('/api/achievements/' + id, {client: 'std'})

    },
    getMapList() {
        return http3.get('/quest/category', {by: 'map', client: 'std'})
    },
    getTaskList(id: any, page: number) {
        return http3.get('/quests', {map_id: id, client: 'std', page: page})
    },
    searchTaskList(str: string, page: number) {
        return http3.get('/quests', {keyword: str, chain: false, page: page, client: 'std'})
    },
    getCopyList(p: number) {
        return http5.get('/api/cms/posts', {type: 'fb', per: '10', page: p, order: 'update', client: 'std'})
    },
    searchCopyList(page: number, val: string) {
        return http5.get('/api/cms/posts?', {
            type: 'fb',
            per: '10',
            page: page,
            order: 'update',
            client: 'std',
            search: val
        })
    },
    getCopyContent(id: string) {
        return http5.get('/api/cms/post/' + id, {})
    },
    searchMeet(r: string, s: string, name: string | null) {
        return http6.get('/qyinfo', {
            m: 1,
            R: r,
            S: s,
            t: '',
            u: '',
            n: name,
            csrf: new Date().getTime()
        })
    }
}

